package com.automannn.seataSamples.order.controller;

import com.automannn.seataSamples.api.dto.OrderDTO;
import com.automannn.seataSamples.api.response.ObjectResponse;
import com.automannn.seataSamples.order.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author automannn
 * @Date 2022/3/24
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IOrderService orderService;

    /**
     * 创建订单
     * @param orderDTO 订单详情
     * @return 创建后的订单详情
     */
    @PostMapping("/create_order")
    public ObjectResponse<OrderDTO> createOrder(@RequestBody OrderDTO orderDTO){
        log.info("请求订单微服务：{}", orderDTO.toString());
        return orderService.createOrder(orderDTO);
    }
}
